<?php

#Load config file
require_once 'conf.php';

#Debug mode
if(DEBUG === TRUE){

  ini_set('display_errors', true);
  error_reporting(E_ALL);

}else{

  ini_set('display_errors', false);

}

#Start session
session_start();

#Charge login or not
if(isset($_SESSION['usr'])){

  #If login get user ID
  $UID = $_SESSION['usr'];

}

#Charge request type
if(isset($_POST['reqpath'])){
#Call API

  #Check request type
  $ReqPath = $_POST['reqpath'];

  #Call C Automaticly If This C Exist
  if(file_exists($BASE_PATH . 'c/' . $ReqPath . '.php')){

    require_once $BASE_PATH . 'c/' . $ReqPath . '.php';

  }else{

    require_once $BASE_PATH . 'c/404.php';

  }

}else{
#Refresh page

  if(isset($UID)){

    #Show Home Page
    require_once $BASE_PATH . 'c/home.php';

  }else{

    #Show Visitor Page
    require_once $BASE_PATH . 'c/visitor.php';

  }

}

